import html2canvas from 'html2canvas';

// 转图片
export function download_img(ref){
    return new Promise(async (resolve,reject)=>{
        //   console.log('ref',ref,ref.offsetHeight)
        let domHeight = ref.offsetHeight
        let maxHeight = 64257

        let canvasres = await html2canvas(ref,{
            backgroundColor: null, // null或transparent可将canvas背景设置为透明
            scale: (maxHeight / domHeight) > 1? 1 : (maxHeight / domHeight)
        })
        let dataURL = canvasres.toDataURL("image/png");
        // return dataURL;
        resolve({dataURL,canvasres})
    })
}
// 下载图片
function fileDown(url, name) {
    const link = document.createElement('a')
    link.href = url
    link.setAttribute('download', name)
    link.style.display = 'none'
    document.body.appendChild(link)
    link.click()
    this.loading_obj.close();
}
